package com.example.myprojectci;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.TimeZone;

@SpringBootApplication
@Slf4j
public class MyprojectCiApplication {

    private static final String WRAP_STR = "/\n\t";

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(MyprojectCiApplication.class);
        Environment env = application.getEnvironment();
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        log.info("\n----------------------------------------------------------\n\t" +
                "Application djp-mss-coupon is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + WRAP_STR +
                "External: \thttp://" + ip + ":" + port + path + WRAP_STR +
                "LocalTime: \ttime://" + LocalDateTime.now() + WRAP_STR +
                "Swagger文档: http://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
    }

}
